using System;
using System.Collections.Generic;
using UnityEngine;

public class level_item_ui : MonoBehaviour
{
	public int levelnum;

	public int battletype;

	public UIEventListener levelbtn;

	public UISprite battleflag;

	public UISprite lockflag;

	public List<GameObject> starobj;

	public List<UISprite> startrueflag;

	private bool islock;

	public bool runflag;

	public UILabel namelabel;

	private void Start()
	{
		UIEventListener uIEventListener = levelbtn;
		uIEventListener.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener.onClick, new UIEventListener.VoidDelegate(OnClicklevelBtn));
	}

	public void showUI(int num, int curlevel)
	{
		if (levelnum <= curlevel)
		{
			islock = false;
			switch (battletype)
			{
				case 1:
					battleflag.spriteName = "ZY_biaoZhiFeiJi";
					break;
				case 2:
					battleflag.spriteName = "ZY_biaoZhiJianZhu";
					break;
				case 3:
					battleflag.spriteName = "ZY_biaoZhiZhanJian";
					break;
			}
			for (int i = 0; i < startrueflag.Count; i++)
			{
				if (i < num)
				{
					startrueflag[i].enabled = true;
				}
				else
				{
					startrueflag[i].enabled = false;
				}
			}
			lockflag.enabled = false;
		}
		else
		{
			islock = true;
			switch (battletype)
			{
				case 1:
					battleflag.spriteName = "ZY_biaoZhiFeiJiHui";
					break;
				case 2:
					battleflag.spriteName = "ZY_biaoZhiJianZhuHui";
					break;
				case 3:
					battleflag.spriteName = "ZY_biaoZhiZhanJianHui";
					break;
			}
			for (int j = 0; j < starobj.Count; j++)
			{
				NGUITools.SetActive(starobj[j], state: false);
			}
			lockflag.enabled = true;
		}
	}

	public void OnClicklevelBtn(GameObject btn)
	{
		if (islock)
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
			MenuUIController.instance.enable_hitinfoui(hitinfoid.levellock);
		}
		else
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
			MenuUIController.instance.enable_startui(levelnum);
		}
	}
}
